package org.sdp.pearproject.service.impl;


import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;
import org.sdp.pearproject.dao.domain.*;
import org.sdp.pearproject.service.*;
import org.sdp.pearproject.service.custom.*;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

/**
 * @ClassName: ProjectMemberServiceImpl
 * @Description:
 * @Author: SDP
 * @Date: 2022-07-12
 * @Version: 1.0
 * Table: pear_project_member
 * Comment:
 * 项目-成员表
 */
@Service
public class ProjectMemberServiceImpl extends ProjectMemberServiceCustomImpl implements ProjectMemberService {

    static {
        beanClassNameMap.put("project_member", "projectMemberServiceImpl");
        listMethodNameMap.put("project_member", "listProjectMember");
        listMethodParameterClassNameMap.put("project_member", "ProjectMemberQueryRequest");
        updateMethodNameMap.put("project_member", "updateProjectMember");
        updateMethodParameterClassNameMap.put("project_member", "ProjectMemberUpdateRequest");
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer addProjectMember(ProjectMemberAddRequest request) throws Exception {
        super.fixRequest("project_member", "add", request);
        return super.addProjectMember(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer updateProjectMember(ProjectMemberUpdateRequest request) throws Exception {
        ProjectMember record = null;
        record = projectMemberMapper.selectByPrimaryKey(request.getId());
        super.fixRequest("project_member", "update", request, record);
        return super.updateProjectMember(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer deleteProjectMember(ProjectMemberDeleteRequest request) throws Exception {
        if (needCheckDeleteList(request)) {
            List<ProjectMember> list = null;
            ProjectMemberExample example = new ProjectMemberExample();
            example.createCriteria().andIdIn(request.getIdList());
            list = projectMemberMapper.selectByExample(example);
            fixRequest("project_member", "delete", request, list);
        } else {
            fixRequest("project_member", "delete", request);
        }
        return super.deleteProjectMember(request);
    }

    @Override
    public ProjectMemberQueryResponse queryProjectMember(ProjectMemberQueryRequest request) throws Exception {
        super.checkNonNull(request.getId(), "id");
        ProjectMemberQueryResponse result = super.queryProjectMember(request);
        checkResult("project_member", "query", request, result);
        return result;
    }

    @Override
    public List<ProjectMemberQueryResponse> listProjectMember(ProjectMemberQueryRequest request) throws Exception {
        List<ProjectMemberQueryResponse> list = super.listProjectMember(request);
        checkResult("project_member", "list", request, list);
        return list;
    }

    @Override
    public Integer countProjectMember(ProjectMemberQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("project_member", "count", request);
        return super.countProjectMember(request);
    }

    @Override
    public BaseStatResponse statProjectMember(ProjectMemberQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("project_member", "stat", request);
        return super.statProjectMember(request);
    }

}
